using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[CreateAssetMenu(menuName = "Data/State/Player/PlayerFly", fileName = "PlayerFly")]
public class PlayerState_Fly : PlayerState
{
    [SerializeField] private float flySpeed;
    //
    public override void Enter()
    {
        base.Enter();
        // 速度设置为零
        playerControl.SetVelocity(Vector2.zero);
        // 设置速度
        playerControl.SetFly(playerStatusInformation.GetFlySpeed * flySpeed);
        // 可以二段跳
        playerDetection.IsCanAirJumo = true;
    }
    
    //
    public override void Exit()
    {
        base.Exit();
        playerStatusInformation.IsFly = false;
    }
    
    //
    public override void LogicUpdate()
    {
        base.LogicUpdate();
        // 速度小于0，并且不在地面  进入下落状态
        if(my_Body2D.velocity.y < 0 && !playerDetection.GetIsGround)
            stateMachine.SwitchState(stateMachine.stateTable[typeof(PlayerState_Fall)]);
        // 如果跳跃，进入二段跳
        if(playerInput.isInputJump && playerDetection.IsCanAirJumo)
            stateMachine.SwitchState(stateMachine.stateTable[typeof(PlayerState_AirJump)]);
    }
    
    //
    public override void PhysicalUpdate()
    {
        base.PhysicalUpdate();
    }
}
